package cn.wizzer.app.web.modules.controllers.platform.bus.bggl;

import cn.wizzer.app.bus.modules.models.YJbxx;
import cn.wizzer.app.bus.modules.services.YJbxxLcxxService;
import cn.wizzer.app.bus.modules.services.YJbxxService;
import cn.wizzer.app.sys.modules.services.SysDictService;
import cn.wizzer.app.sys.modules.services.SysUnitService;
import cn.wizzer.app.sys.modules.services.SysUserService;
import cn.wizzer.app.web.commons.slog.annotation.SLog;
import cn.wizzer.app.web.commons.utils.ShiroUtil;
import cn.wizzer.framework.base.Result;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.log.Log;
import org.nutz.log.Logs;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param;


/**
 * 报告审核  虞秀斌  2019-11
 */
@IocBean
@At("/platform/bus/bggl")
public class PrintController {
    private static final Log log = Logs.get();
    @Inject
    private YJbxxService yjbxxService;
    @Inject
    private YJbxxLcxxService yjbxxlcxxservice;
    @Inject
    private SysUnitService sysUnitService;
    @Inject
    private SysDictService sysDictService;
    @Inject
    private SysUserService sysUserService;
    @Inject
    private ShiroUtil shiroUtil;

    @At
    @Ok("json")
    @RequiresPermissions("bus.bggl")
    @SLog(tag = "报告打印", msg = "样品:${args[0].ypbh}")
    public Object printDo(@Param("..") YJbxx obj) {
        try {
            YJbxx jbxx = yjbxxService.fetch(obj.getId());
            jbxx.setDyzt("1");
            yjbxxService.update(jbxx);
            yjbxxlcxxservice.clearCache();
            return Result.success("打印标记成功！");
        } catch (Exception e) {
            return Result.error("system.error");
        }
    }
}
